package com.example.administrator.dc.model;

import android.content.Context;
import android.content.SharedPreferences;
import android.support.v7.widget.LinearLayoutManager;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.example.administrator.dc.Activity.CollectActivity;
import com.example.administrator.dc.Bean.Checkcollect;
import com.example.administrator.dc.Bean.Collectlistresult;
import com.example.administrator.dc.Bean.Collectresult;
import com.example.administrator.dc.Bean.UnCollectresult;
import com.example.administrator.dc.Service.CollectListener;
import com.example.administrator.dc.Service.CollectService;
import com.example.administrator.dc.adapter.CollectlistAdapter;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by Administrator on 2017/8/21.
 */

public class CollectModel {
    Retrofit retrofit;
    private Context mContext;
    private CollectActivity collectActivity;

    public  void collect(String uid,int bid,final CollectListener listener) {
        Retrofit retrofit=new Retrofit.Builder().baseUrl(Contants.BASE_URL1).
                addConverterFactory(GsonConverterFactory.create()).build();
        CollectService service=retrofit.create(CollectService.class);
        Call<Collectresult> call= service.collectresultCall(uid,bid);
        call.enqueue(new Callback<Collectresult>() {
            @Override
            public void onResponse(Call<Collectresult> call, Response<Collectresult> response) {
                if(response.body().getStatus()==1){
                    System.out.println("收藏成功");
                }
                else {

                }
            }

            @Override
            public void onFailure(Call<Collectresult> call, Throwable t) {

            }
        });


    }
    public  void  uncollect(String uid,int bid,final CollectListener listener){
        Retrofit retrofit=new Retrofit.Builder().baseUrl(Contants.BASE_URL1).
                addConverterFactory(GsonConverterFactory.create()).build();
        CollectService service=retrofit.create(CollectService.class);
        Call<UnCollectresult> call=service.uncollectresult(uid,bid);
        call.enqueue(new Callback<UnCollectresult>() {
            @Override
            public void onResponse(Call<UnCollectresult> call, Response<UnCollectresult> response) {
                if(response.body().getStatus()==1){
                    listener.onResponse1("yes");
                    System.out.println("取消收藏成功");
                }
                else {
                }
            }

            @Override
            public void onFailure(Call<UnCollectresult> call, Throwable t) {

            }
        });



    }
    public  void  collectlist(String uid){

    }

}
